| complex (1) | template<class T> T real (const complex<T>& x); |
|---|
| complex (1) | template<class T> T real (const complex<T>& x); |
|---|---|
| arithmetic type (2) | double real (ArithmeticType x); // additional overloads |
x.real() .x.real() for (1).double, except if the argument is float or long double (in which case, the return type is of the same type as the argument).1
2
3
4
5
6
7
8
9
10
11
12
// std::real example
#include <iostream> // std::cout
#include <complex> // std::complex, std::real
int main ()
{
std::complex<double> mycomplex (10.0,1.0);
std::cout << "Real part: " << std::real(mycomplex) << '\n';
return 0;
}
Real part: 10